CREATE PROCEDURE RRHH_BUSCAR_ACTIVIDADES_PASADAS_L
@IDEMPLEADO INT,
@FECHA DATETIME
AS
--SET TRANSACTION ISOLATION LEVEL SERIALIZABLE

BEGIN TRANSACTION

BEGIN TRY
	SELECT * FROM AGENDAACTIVIDAD
	WHERE idEmpleado = @IDEMPLEADO AND
		  CAST(fecha AS DATE) < CAST(@FECHA AS DATE) AND
		  ESTADO = 1
	ORDER BY CAST(fecha as DATE),
	         CAST(horaInicioAct AS TIME)
	COMMIT TRANSACTION
END TRY
BEGIN CATCH
	ROLLBACK TRANSACTION
END CATCH